#include "StringEditor.h"


StringEditor::StringEditor(int lineNum, int startPos, int endPos) : BasicEditor(lineNum, startPos, endPos, EditorType::STRING), mindex{0} {
//    blankText = textBuffer;
//    textBuffer.clear();
}



int StringEditor::onKeyDown(const KeyCode& keyCode) {
    if (mindex) {
        textBuffer[--mindex] = 0;
    }

    return 2;
}


int StringEditor::onOtherKey(const KeyCode& keyCode) {
    LOG_DEDUG("%s,received:%d", __func__, keyCode);
    if (KeyCode::CHANNEL_MAX > keyCode && mindex < maxCharactor) {
        textBuffer[mindex++] = '1' + keyCode % 9;
    }
    return 2;
}


/*
int StringEditor::onKeyPressed(const KeyCode& keyCode) {
    int result = 0;
    LOG_DEDUG("%s,received:%d", __func__, keyCode);
    if (KeyCode::CHANNEL_MAX > keyCode && mindex < maxCharactor) {
        textBuffer.append(mindex++, '0' + keyCode);
        result = 2;
    } else {
        result = BasicEditor::onKeyPressed(keyCode);
    }

    return result;
}
*/




